package com.ruoyi.subject.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.subject.domain.SubjectSystem;
import com.ruoyi.subject.service.ISubjectSystemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管理制度Controller
 * 
 * @author yepanpan
 * @date 2021-03-15
 */
@Api("管理制度管理")
@RestController
@RequestMapping("/subject/system")
public class SubjectSystemController extends BaseController
{
    @Autowired
    private ISubjectSystemService subjectSystemService;

    /**
     * 查询管理制度列表
     */
    @ApiOperation("查询管理制度列表")   
    @GetMapping("/list")
    public TableDataInfo list(SubjectSystem subjectSystem)
    {
        startPage();
        List<SubjectSystem> list = subjectSystemService.selectSubjectSystemList(subjectSystem);
        return getDataTable(list);
    }

    /**
     * 导出管理制度列表
     */
    @ApiOperation("导出管理制度列表")    
    @PreAuthorize("@ss.hasPermi('subject:system:export')")
    @Log(title = "管理制度", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SubjectSystem subjectSystem)
    {
        List<SubjectSystem> list = subjectSystemService.selectSubjectSystemList(subjectSystem);
        ExcelUtil<SubjectSystem> util = new ExcelUtil<SubjectSystem>(SubjectSystem.class);
        return util.exportExcel(list, "system");
    }

    /**
     * 获取管理制度详细信息
     */
    @ApiOperation("获取管理制度详细信息")
    @ApiImplicitParam(name = "id", value = "管理制度ID", required = true, dataType = "int", paramType = "path") 
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(subjectSystemService.selectSubjectSystemById(id));
    }

    /**
     * 新增管理制度
     */
    @ApiOperation("新增管理制度")
    @PreAuthorize("@ss.hasPermi('subject:system:add')")
    @Log(title = "管理制度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubjectSystem subjectSystem)
    {
        return toAjax(subjectSystemService.insertSubjectSystem(subjectSystem));
    }

    /**
     * 修改管理制度
     */
    @ApiOperation("修改管理制度")  
    @PreAuthorize("@ss.hasPermi('subject:system:edit')")
    @Log(title = "管理制度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubjectSystem subjectSystem)
    {
        return toAjax(subjectSystemService.updateSubjectSystem(subjectSystem));
    }

    /**
     * 删除管理制度
     */
    @ApiOperation("删除管理制度")
    @ApiImplicitParam(name = "id", value = "管理制度ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('subject:system:remove')")
    @Log(title = "管理制度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(subjectSystemService.deleteSubjectSystemByIds(ids));
    }
}
